/* -----------------------------------------------------------------------------
 * PROJECT    : net.lwf
 * FILE       : WordImage.java
 *
 * HISTORY:
 * Date          Author                        Description
 * ----------------------------------------------------------------------------- 
 * Dec 19, 2008       Raghu Sarraff			       Created
 */
package lwf.handler.entities;

import java.util.ArrayList;
import java.util.List;

import net.lwf.handler.constant.IHandlerConstant;



/**
 * Type the class description here
 *  
 */
public class WordImage {
	
	private String word;
	private String imageName;
	private String imagePath;
	private List wordimages;
	
	private boolean simple = false;     //3
	private boolean verySimple = false; //1 or 2 words
	private boolean medium = false;     //4 or 5
	private boolean abovemedium = false;//6 or 7
	private boolean hard = false;       //over 7 
	
	public WordImage(String imagename, String imagepath) {
		this.imageName = imagename; //many not be needed
		//Parse for word
		this.word = imagename.substring(0, imagename.indexOf("."));
		//Image path
		setImagePath(imagepath);
	}
	
	public void add(WordImage wordimage) {
		if(wordimages == null) {
			wordimages = new ArrayList();
			wordimages.add(this);
		}
		wordimages.add(wordimage);
	}
	
	/**
	 * @return Returns the imageName.
	 */
	public String getImageName() {
		return imageName;
	}
	
	/**
	 * @return Returns the imagePath.
	 */
	public String getImagePath() {
		return imagePath;
	}

	public List getWordImages() {
		return wordimages;
	}

	/**
	 * @return Returns the word.
	 */
	public String getWord() {
		return word;
	}
	
	public void print() {
		System.out.println("=======> Image: " + getImageName() + ", Path: " + getImagePath() + ", Word: " + getWord());
	}
	
	private void setImagePath(String _imagepath) {
		if(_imagepath != null && _imagepath.trim().length() != 0) {
			StringBuffer strBuff = new StringBuffer("/" + IHandlerConstant.CONTEXT_PATH + "/");
			char c;
			String base = String.valueOf('\\');
			for (int i = 0; i < _imagepath.length(); i++) {
				c = _imagepath.charAt(i);
				if (String.valueOf(c).equals(base)) {
					c = '/';
				} 
				strBuff.append(c);
			}
			String path = strBuff.toString();
			this.imagePath = strBuff.toString();
		}

	}
	
}

